- breadcrumb_title _("General Settings")
- page_title _("General")
- add_page_specific_style 'page_bundles/projects_edit'
- reduce_visibility_form_id = 'reduce-visibility-form'
- duo_settings_form_id = 'duo-settings-form'
- @force_desktop_expanded_sidebar = true
- project_docs_path = help_page_path('user/project/working_with_projects.md')
- project_docs_link_start = '<a href="%{url}" target="_blank">'.html_safe % { url: project_docs_path }

%h1.gl-sr-only= @breadcrumb_title

- if can?(current_user, :admin_project, @project)
  = render ::Layouts::SettingsBlockComponent.new(_('Naming, description, topics'),
    id: 'js-general-settings',
    testid: 'general-settings-content',
    expanded: true) do |c|
    - c.with_description do
      = html_escape(_('Update your project name, description, avatar, and topics. %{link_start}Learn more about projects%{link_end}.')) % { link_start: project_docs_link_start, link_end: '</a>'.html_safe }
    - c.with_body do
      = render 'projects/settings/general'

  = render ::Layouts::SettingsBlockComponent.new(_('Visibility, project features, permissions'),
    id: 'js-shared-permissions',
    testid: 'visibility-features-permissions-content',
    expanded: expanded_by_default?) do |c|
    - c.with_description do
      = _('Choose visibility level, enable/disable project features and their permissions, disable email notifications, and show default emoji reactions.')
    - c.with_body do
      = form_for @project, html: { multipart: true, class: "sharing-permissions-form", id: reduce_visibility_form_id }, authenticity_token: true do |f|
        %input{ name: 'update_section', type: 'hidden', value: 'js-shared-permissions' }
        %template.js-project-permissions-form-data{ type: "application/json" }= project_permissions_panel_data(@project).to_json.html_safe
        .js-project-permissions-form{ data: project_permissions_data(@project, reduce_visibility_form_id) }

  = render ::Layouts::SettingsBlockComponent.new(s_('ProjectSettings|Badges'),
    id: 'js-badges-settings',
    testid: 'badges-settings-content',
    expanded: expanded_by_default?) do |c|
    - c.with_description do
      = s_('ProjectSettings|Add badges to display information about this project.')
      = link_to s_('ProjectSettings|What are badges?'), help_page_path('user/project/badges.md')
    - c.with_body do
      = render 'shared/badges/badge_settings'

  - if @project.licensed_ai_features_available?
    = render ::Layouts::SettingsBlockComponent.new(s_('ProjectSettings|GitLab Duo'),
      id: 'js-gitlab-duo-settings',
      testid: 'gitlab-duo-settings-content',
      expanded: expanded_by_default?) do |c|
      - c.with_description do
        = s_('ProjectSettings|Configure GitLab Duo features for this project.')
      - c.with_body do
        = form_for @project, html: { multipart: true, class: "duo-settings-form", id: duo_settings_form_id }, authenticity_token: true do |f|
          %template.js-gitlab-duo-settings-form-data{ type: "application/json" }= gitlab_duo_settings_data(@project).to_json.html_safe
          .js-gitlab-duo-settings-form{ data: { targetFormId: duo_settings_form_id } }

  = render_if_exists 'projects/settings/default_issue_template'

  = render 'projects/service_desk_settings'

  = render ::Layouts::SettingsBlockComponent.new(_('Advanced'),
    id: 'js-project-advanced-settings',
    testid: 'advanced-settings-content',
    expanded: expanded_by_default?) do |c|
    - c.with_description do
      = s_('ProjectSettings|Housekeeping, export, archive, change path, transfer, and delete.')
    - c.with_body do
      .gl-flex.gl-gap-5.gl-flex-col
        = render Pajamas::CardComponent.new do |c|
          - c.with_header do
            .gl-flex.gl-grow
              %h4.gl-text-base.gl-leading-24.gl-m-0= _('Housekeeping')
            %p.gl-text-subtle.gl-text-sm.gl-m-0
              = _('Runs a number of housekeeping tasks within the current repository, such as compressing file revisions and removing unreachable objects.')
              = link_to _('Learn more.'), help_page_path('administration/housekeeping.md'), target: '_blank', rel: 'noopener noreferrer'

          - c.with_body do
            .gl-flex.gl-flex-wrap.gl-gap-3
              = render Pajamas::ButtonComponent.new(method: :post, href: housekeeping_project_path(@project)) do
                = _('Run housekeeping')
              #js-project-prune-unreachable-objects-button{ data: { prune_objects_path: housekeeping_project_path(@project, prune: true), prune_objects_doc_path: help_page_path('administration/housekeeping.md', anchor: 'prune-unreachable-objects') } }

        = render 'export', project: @project

        = render 'projects/settings/archive', project: @project

        = render Pajamas::CardComponent.new do |c|
          - c.with_header do
            .gl-flex.gl-grow
              %h4.gl-text-base.gl-leading-24.gl-m-0= _('Change path')
            %p.gl-text-subtle.gl-text-sm.gl-m-0
              - link = link_to('', help_page_path('user/project/working_with_projects.md', anchor: 'rename-a-repository'), target: '_blank', rel: 'noopener noreferrer')
              = safe_format(_("A project’s repository name defines its URL (the one you use to access the project via a browser). %{link_start}Learn more.%{link_end}"), tag_pair(link, :link_start, :link_end))

          - c.with_body do
            = render 'projects/errors'
            = gitlab_ui_form_for @project do |f|
              .form-group
                %ul
                  %li= _("Be careful. Renaming a project's repository can have unintended side effects.")
                  %li= _('You will need to update your local repositories to point to the new location.')
                  - if ContainerRegistry::GitlabApiClient.supports_gitlab_api?
                    %li= s_('ContainerRegistry|While the rename is in progress, new uploads to the container registry are blocked. Ongoing uploads may fail and need to be retried.')
                - if @project.deployment_platform.present?
                  %p= _('Your deployment services will be broken, you will need to manually fix the services after renaming.')
                = f.label :path, _('Path'), class: 'label-bold'
                .form-group
                  .input-group
                    .input-group-prepend
                      .input-group-text
                        #{Gitlab::Utils.append_path(root_url, @project.namespace.full_path)}/
                    = f.text_field :path, class: 'form-control gl-form-input-xl', data: { testid: 'project-path-field' }
              = f.submit _('Change path'), class: "btn-danger", data: { testid: 'change-path-button' }, pajamas_button: true

        = render 'transfer', project: @project

        = render 'remove_fork', project: @project

        = render 'shared/groups_projects/settings/restore', context: @project
        = render 'delete'
- else
  = render 'projects/settings/archive', project: @project
  = render 'delete'

.save-project-loader.hide
  .center
    %h2
      = gl_loading_icon(inline: true, size: 'md', css_class: 'gl-align-middle')
      = _('Saving project.')
    %p= _('Please wait a moment, this page will automatically refresh when ready.')
